<?php

namespace App\Exceptions;

class ServiceExceptionConstant
{

    public static function getErrorData($key)
    {
        if (!array_key_exists($key, self::errorArray())) {
            return ['code' => 11001, 'msg' => $key];
        }
        return self::errorArray()[$key];
    }

    public static function errorArray()
    {
        return [
            'need_login'                => ['code' => 10001, 'msg' => '需要登录后才能访问'],
            'account_band'              => ['code' => 10002, 'msg' => '账户已被禁用'],
            'account_invalid'           => ['code' => 10003, 'msg' => '账户不存在'],
            'account_password_invalid'  => ['code' => 10004, 'msg' => '账号密码错误'],
            'db_data_invalid'           => ['code' => 10005, 'msg' => '当前编辑数据不存在'],
            'data_save_failed'          => ['code' => 10006, 'msg' => '保存数据失败'],
            'wx_api_invalid'            => ['code' => 10007, 'msg' => '登录异常,请重试'],
            'login_failed'              => ['code' => 10008, 'msg' => '登录失败'],
            'upload_failed'             => ['code' => 10009, 'msg' => '上传失败'],
            'address_invalid'           => ['code' => 10010, 'msg' => '收货地址不存在'],
            'goods_invalid'             => ['code' => 10011, 'msg' => '商品不存在或已下架'],
            'order_create_failed'       => ['code' => 10012, 'msg' => '下单失败'],
            'wechat_unify_order_failed' => ['code' => 10013, 'msg' => '统一下单失败'],
            'param_error'               => ['code' => 10014, 'msg' => '参数错误'],
            'image_save_failed'         => ['code' => 10015, 'msg' => '图片保存失败'],
            'file_save_failed'          => ['code' => 10016, 'msg' => '文件保存失败'],
            'store_invalid'             => ['code' => 10017, 'msg' => '库存不足'],
            'operation_failed'          => ['code' => 10018, 'msg' => '操作失败'],
        ];
    }
}
